package com.byxy.action;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;

import com.byxy.aspect.MyLog;
import com.byxy.entity.Agency;
import com.byxy.service.AgencyService;

public class AgencyUpdateAction {
	private Integer id; // 序号
	private String name; // 旅行社名称
	private String code; // 旅行社代码
	private String phone; // 旅行社电话
	private String email; // 旅行社邮箱
	private String remark; // 备注
	private Agency agency;

	@Resource
	private AgencyService agencyService;

	public Agency getAgency() {
		return agency;
	}

	public void setAgency(Agency agency) {
		this.agency = agency;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@MyLog(desc = "数据更新")
	public String update() {
		if ("POST".equalsIgnoreCase(ServletActionContext.getRequest().getMethod())) {
			agency = new Agency(id, name, code, phone, email, remark);
			agencyService.update(agency);
			return "post";
		} else {
			agency = agencyService.getById(id);
			return "get";
		}
	}
}
